<script>
	import request from './utils/request'
	export default {
		globalData: {
			apiBase: "https://my-park.nightkper.com/"
		},
		onLaunch: function() {

			// 1.先从缓存中取出token
			const _token = uni.getStorageSync('api_token')

			// 2.判断token是否有值
			if (_token != '') { //已有token，验证token是否过期
				let _this = this
				uni.login({
					success(result) {
						let code = result.code
						_this.request.get(`wechat/mini/login`, {
							code
						}).then((res) => {
							const token = res.data.token
							uni.setStorageSync('api_token', token)
						})
					}
				})
			} else { //没有token,进行登录操作
				console.log('执行了登录操作')
			}
		},
		onShow: function() {
			
		},
		onHide: function() {
			uni.removeTabBarBadge()
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	/*每个页面公共css */
</style>
